package com.tsmti.system.entity;

import com.tsmti.core.common.entity.BaseDataEntity;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Where;

import javax.persistence.*;
import java.util.Date;

/**
 * Title：PimsSystem
 * Class：com.ts.sys.entity
 * Comapny:
 *
 * @author：zcw
 * @version：2.5 CreateTime：2018/1/17 11:06
 * Modify log:
 * Description：
 */
@Entity
@Table(name = "pims_log")
@DynamicUpdate
@DynamicInsert
@SuppressWarnings("serial")
@Where(clause = "delFlag = 0")
public class Log extends BaseDataEntity<String> {

    /**
     * 日志类型（1：接入日志；2：错误日志）
     */
    public static final String TYPE_ACCESS = "1";
    public static final String TYPE_EXCEPTION = "2";

    /** 编号 */
    private String id;
    /** 用户代理 */
    private String userAgent;
    /** 请求URI */
    private String requestUri;
    /** 日志标题 */
    private String title;
    /** 日志类型 */
    private String type;
    /** 操作方式 */
    private String method;
    /** 异常信息 */
    private String exception;
    /** 日志内容 */
    private String content;
    /** 操作方式 */
    private String logType;
    /** 操作提交的数据 */
    private String params;
    /** 操作IP地址 */
    private String remoteAddr;

    /**获取ID*/
    @Id
    @GeneratedValue(generator = "idGenerator")
    @GenericGenerator(name = "idGenerator", strategy = "uuid")
    @Column(name = "id", nullable = false, length = 64)
    @Override
    public String getId() {
        return id;
    }

    /**设置ID*/
    @Override
    public void setId(String id) {
        this.id = id;
    }

    public String getUserAgent() {
        return userAgent;
    }

    public void setUserAgent(String userAgent) {
        this.userAgent = userAgent;
    }

    public String getRequestUri() {
        return requestUri;
    }

    public void setRequestUri(String requestUri) {
        this.requestUri = requestUri;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getMethod() {
        return method;
    }

    public void setMethod(String method) {
        this.method = method;
    }

    @Column(name = "EXCEPTION", columnDefinition = "CLOB", nullable = true)
    public String getException() {
        return exception;
    }

    public void setException(String exception) {
        this.exception = exception;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getLogType() {
        return logType;
    }

    public void setLogType(String logType) {
        this.logType = logType;
    }

    @Column(name = "PARAMS", columnDefinition = "CLOB", nullable = true)
    public String getParams() {
        return params;
    }

    public void setParams(String params) {
        this.params = params;
    }

    public String getRemoteAddr() {
        return remoteAddr;
    }

    public void setRemoteAddr(String remoteAddr) {
        this.remoteAddr = remoteAddr;
    }


    @Override
    public String toString() {
        super.toString();
        return "Log{" +
                "id='" + id + '\'' +
                ", userAgent='" + userAgent + '\'' +
                ", requestUri='" + requestUri + '\'' +
                ", title='" + title + '\'' +
                ", type='" + type + '\'' +
                ", method='" + method + '\'' +
                ", exception='" + exception + '\'' +
                ", content='" + content + '\'' +
                ", logType='" + logType + '\'' +
                ", createDate=" + createDate +
                ", params='" + params + '\'' +
                ", remoteAddr='" + remoteAddr + '\'' +
                '}';
    }
}
